import { createStore } from 'vuex'

import user from './user'

export default createStore({
    state: {

        websocket: null,
        chat_id: null,
        // websocket 连接地址
        websocket_path: "ws://127.0.0.1:8000/ws/chat/",
        // 用户在线
        websocket_user_path: "ws://127.0.0.1:8000/ws/user/",
    },
    getters: {
        getChat_id(state) {
            return state.chat_id
        },
    },
    mutations: {
        setChat_id(state, data) {
            state.chat_id = data;
        },

    },
    actions: {
        //传入的第一个参数是context---->获取{commit}
        setChat_id({ commit }, data) {
            commit('setChat_id', data);
        },
    },
    modules: {
        user,
    }
})
